<?php
namespace app\know\controller;

use app\know\controller\AdminKnowBaseController;
use app\know\model\NewWordExpandModel;
use app\know\validate\NewWordExpandValidate;
use think\facade\Db;
use think\facade\Log;

/**
 * Class AdminNewWordExpandController 词汇扩展管理控制器
 * @package app\know\controller
 */
class AdminNewWordExpandController extends AdminKnowBaseController
{

    
	public function delete()
    {
        $param = $this->request->param();
        $id = $this->request->param('id', '');
        
        try 
		{
            $this->validateFailError($param, 'NewWordExpand.delete');
        } 
		catch (ValidateException $e) 
		{
            $this->error($e->getError());
        }

        $user = $this->getAdminUser();
        $param['modify_user'] = $user['user_login'];

        try 
		{
            NewWordExpandModel::where('id', 'in', preg_split("/[\s;,]/", $id))->save(['is_delete' => 1]);
            $this->opLog([
                'table_name' => (new NewWordExpandModel())->getTableName(),
                'sql' => NewWordExpandModel::getLastSql(),
                'create_user' => $user['user_login'],
                'before_data' => json_encode($id),
            ]);
        } 
		catch (\Throwable $th) 
		{
            $this->error($th->getMessage());
        }
        $this->success('已删除');
    }
	

    public function maxOrder()
    {
        $order = NewWordExpandModel::max('order_number');
        $this->success('', '', $order);
    }

}
